//
//  LJLRadioPageTVC.m
//  聆听FM
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "LJLRadioPageTVC.h"
#import "LJLRecommandRadioCVC.h"
@implementation LJLRadioPageTVC


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.minimumLineSpacing = 10 * FITWIDTH;
        flowLayout.minimumInteritemSpacing = 0 * FITHEIGHT;
        flowLayout.itemSize = CGSizeMake((SCREENWIDTH - 40 * FITWIDTH) / 3.0, 110 * FITHEIGHT);
        flowLayout.sectionInset = UIEdgeInsetsMake(0 * FITWIDTH, 10 * FITHEIGHT, 10 * FITWIDTH,10 * FITHEIGHT);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        self.radioPageCV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 170 * FITHEIGHT) collectionViewLayout:flowLayout];
        self.radioPageCV.backgroundColor = [UIColor clearColor];
        self.radioPageCV.delegate = self;
        self.radioPageCV.dataSource = self;
        [self.contentView addSubview:_radioPageCV];
        
        [self.radioPageCV registerClass:[LJLRecommandRadioCVC class] forCellWithReuseIdentifier:@"LJLrecommandradioCVC"];
    }
    return self;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    LJLRecommandRadioCVC *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LJLrecommandradioCVC" forIndexPath:indexPath];
    cell.model = [self.dataArray objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    self.rBlock(indexPath.row);
}

- (void)setDataArray:(NSMutableArray *)dataArray
{
    if (_dataArray != dataArray) {
       
        _dataArray = dataArray;
        if (dataArray) {
            [self.radioPageCV reloadData];
        }
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
